#ifndef THINK_THINK_CONSOLE_H
#define THINK_THINK_CONSOLE_H

static char* think_console =
	"\n"
	"// +----------------------------------------------------------------------\n"
	"// | TopThink [ WE CAN DO IT JUST THINK IT ]\n"
	"// +----------------------------------------------------------------------\n"
	"// | Copyright (c) 2015 http://www.topthink.com All rights reserved.\n"
	"// +----------------------------------------------------------------------\n"
	"// | Author: zhangyajun <448901948@qq.com>\n"
	"// +----------------------------------------------------------------------\n"
	"\n"
	"namespace think;\n"
	"\n"
	"use think\\console\\Command;\n"
	"use think\\console\\command\\Help as HelpCommand;\n"
	"use think\\console\\Input;\n"
	"use think\\console\\input\\Argument as InputArgument;\n"
	"use think\\console\\input\\Definition as InputDefinition;\n"
	"use think\\console\\input\\Option as InputOption;\n"
	"use think\\console\\Output;\n"
	"use think\\console\\output\\driver\\Buffer;\n"
	"\n"
	"class Console\n"
	"{\n"
	"    /**\n"
	"     * @var string 命令名称\n"
	"     */\n"
	"    private $name;\n"
	"\n"
	"    /**\n"
	"     * @var string 命令版本\n"
	"     */\n"
	"    private $version;\n"
	"\n"
	"    /**\n"
	"     * @var Command[] 命令\n"
	"     */\n"
	"    private $commands = [];\n"
	"\n"
	"    /**\n"
	"     * @var bool 是否需要帮助信息\n"
	"     */\n"
	"    private $wantHelps = false;\n"
	"\n"
	"    /**\n"
	"     * @var bool 是否捕获异常\n"
	"     */\n"
	"    private $catchExceptions = true;\n"
	"\n"
	"    /**\n"
	"     * @var bool 是否自动退出执行\n"
	"     */\n"
	"    private $autoExit = true;\n"
	"\n"
	"    /**\n"
	"     * @var InputDefinition 输入定义\n"
	"     */\n"
	"    private $definition;\n"
	"\n"
	"    /**\n"
	"     * @var string 默认执行的命令\n"
	"     */\n"
	"    private $defaultCommand;\n"
	"\n"
	"    /**\n"
	"     * @var array 默认提供的命令\n"
	"     */\n"
	"    private static $defaultCommands = [\n"
	"        \"think\\\\console\\\\command\\\\Help\",\n"
	"        \"think\\\\console\\\\command\\\\Lists\",\n"
	"        \"think\\\\console\\\\command\\\\Build\",\n"
	"        \"think\\\\console\\\\command\\\\Clear\",\n"
	"        \"think\\\\console\\\\command\\\\make\\\\Controller\",\n"
	"        \"think\\\\console\\\\command\\\\make\\\\Model\",\n"
	"        \"think\\\\console\\\\command\\\\optimize\\\\Autoload\",\n"
	"        \"think\\\\console\\\\command\\\\optimize\\\\Config\",\n"
	"        \"think\\\\console\\\\command\\\\optimize\\\\Route\",\n"
	"        \"think\\\\console\\\\command\\\\optimize\\\\Schema\",\n"
	"    ];\n"
	"\n"
	"    /**\n"
	"     * Console constructor.\n"
	"     * @access public\n"
	"     * @param  string     $name    名称\n"
	"     * @param  string     $version 版本\n"
	"     * @param null|string $user    执行用户\n"
	"     */\n"
	"    public function __construct($name = \'UNKNOWN\', $version = \'UNKNOWN\', $user = null)\n"
	"    {\n"
	"        $this->name    = $name;\n"
	"        $this->version = $version;\n"
	"\n"
	"        if ($user) {\n"
	"            $this->setUser($user);\n"
	"        }\n"
	"\n"
	"        $this->defaultCommand = \'list\';\n"
	"        $this->definition     = $this->getDefaultInputDefinition();\n"
	"\n"
	"        foreach ($this->getDefaultCommands() as $command) {\n"
	"            $this->add($command);\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置执行用户\n"
	"     * @param $user\n"
	"     */\n"
	"    public function setUser($user)\n"
	"    {\n"
	"        $user = posix_getpwnam($user);\n"
	"        if ($user) {\n"
	"            posix_setuid($user[\'uid\']);\n"
	"            posix_setgid($user[\'gid\']);\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 初始化 Console\n"
	"     * @access public\n"
	"     * @param  bool $run 是否运行 Console\n"
	"     * @return int|Console\n"
	"     */\n"
	"    public static function init($run = true)\n"
	"    {\n"
	"        static $console;\n"
	"\n"
	"        if (!$console) {\n"
	"            $config = Config::get(\'console\');\n"
	"            // 实例化 console\n"
	"            $console = new self($config[\'name\'], $config[\'version\'], $config[\'user\']);\n"
	"\n"
	"            // 读取指令集\n"
	"            if (is_file(CONF_PATH . \'command\' . EXT)) {\n"
	"                $commands = include CONF_PATH . \'command\' . EXT;\n"
	"\n"
	"                if (is_array($commands)) {\n"
	"                    foreach ($commands as $command) {\n"
	"                        class_exists($command) &&\n"
	"                        is_subclass_of($command, \"\\\\think\\\\console\\\\Command\") &&\n"
	"                        $console->add(new $command());  // 注册指令\n"
	"                    }\n"
	"                }\n"
	"            }\n"
	"        }\n"
	"\n"
	"        return $run ? $console->run() : $console;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 调用命令\n"
	"     * @access public\n"
	"     * @param  string $command\n"
	"     * @param  array  $parameters\n"
	"     * @param  string $driver\n"
	"     * @return Output\n"
	"     */\n"
	"    public static function call($command, array $parameters = [], $driver = \'buffer\')\n"
	"    {\n"
	"        $console = self::init(false);\n"
	"\n"
	"        array_unshift($parameters, $command);\n"
	"\n"
	"        $input  = new Input($parameters);\n"
	"        $output = new Output($driver);\n"
	"\n"
	"        $console->setCatchExceptions(false);\n"
	"        $console->find($command)->run($input, $output);\n"
	"\n"
	"        return $output;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 执行当前的指令\n"
	"     * @access public\n"
	"     * @return int\n"
	"     * @throws \\Exception\n"
	"     */\n"
	"    public function run()\n"
	"    {\n"
	"        $input  = new Input();\n"
	"        $output = new Output();\n"
	"\n"
	"        $this->configureIO($input, $output);\n"
	"\n"
	"        try {\n"
	"            $exitCode = $this->doRun($input, $output);\n"
	"        } catch (\\Exception $e) {\n"
	"            if (!$this->catchExceptions) throw $e;\n"
	"\n"
	"            $output->renderException($e);\n"
	"\n"
	"            $exitCode = $e->getCode();\n"
	"\n"
	"            if (is_numeric($exitCode)) {\n"
	"                $exitCode = ((int) $exitCode) ?: 1;\n"
	"            } else {\n"
	"                $exitCode = 1;\n"
	"            }\n"
	"        }\n"
	"\n"
	"        if ($this->autoExit) {\n"
	"            if ($exitCode > 255) $exitCode = 255;\n"
	"\n"
	"            exit($exitCode);\n"
	"        }\n"
	"\n"
	"        return $exitCode;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 执行指令\n"
	"     * @access public\n"
	"     * @param  Input  $input  输入\n"
	"     * @param  Output $output 输出\n"
	"     * @return int\n"
	"     */\n"
	"    public function doRun(Input $input, Output $output)\n"
	"    {\n"
	"        // 获取版本信息\n"
	"        if (true === $input->hasParameterOption([\'--version\', \'-V\'])) {\n"
	"            $output->writeln($this->getLongVersion());\n"
	"\n"
	"            return 0;\n"
	"        }\n"
	"\n"
	"        $name = $this->getCommandName($input);\n"
	"\n"
	"        // 获取帮助信息\n"
	"        if (true === $input->hasParameterOption([\'--help\', \'-h\'])) {\n"
	"            if (!$name) {\n"
	"                $name  = \'help\';\n"
	"                $input = new Input([\'help\']);\n"
	"            } else {\n"
	"                $this->wantHelps = true;\n"
	"            }\n"
	"        }\n"
	"\n"
	"        if (!$name) {\n"
	"            $name  = $this->defaultCommand;\n"
	"            $input = new Input([$this->defaultCommand]);\n"
	"        }\n"
	"\n"
	"        return $this->doRunCommand($this->find($name), $input, $output);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置输入参数定义\n"
	"     * @access public\n"
	"     * @param  InputDefinition $definition 输入定义\n"
	"     * @return $this;\n"
	"     */\n"
	"    public function setDefinition(InputDefinition $definition)\n"
	"    {\n"
	"        $this->definition = $definition;\n"
	"\n"
	"        return $this;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取输入参数定义\n"
	"     * @access public\n"
	"     * @return InputDefinition\n"
	"     */\n"
	"    public function getDefinition()\n"
	"    {\n"
	"        return $this->definition;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取帮助信息\n"
	"     * @access public\n"
	"     * @return string\n"
	"     */\n"
	"    public function getHelp()\n"
	"    {\n"
	"        return $this->getLongVersion();\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置是否捕获异常\n"
	"     * @access public\n"
	"     * @param bool $boolean 是否捕获\n"
	"     * @return $this\n"
	"     */\n"
	"    public function setCatchExceptions($boolean)\n"
	"    {\n"
	"        $this->catchExceptions = (bool) $boolean;\n"
	"\n"
	"        return $this;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置是否自动退出\n"
	"     * @access public\n"
	"     * @param bool $boolean 是否自动退出\n"
	"     * @return $this\n"
	"     */\n"
	"    public function setAutoExit($boolean)\n"
	"    {\n"
	"        $this->autoExit = (bool) $boolean;\n"
	"\n"
	"        return $this;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取名称\n"
	"     * @access public\n"
	"     * @return string\n"
	"     */\n"
	"    public function getName()\n"
	"    {\n"
	"        return $this->name;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置名称\n"
	"     * @access public\n"
	"     * @param  string $name 名称\n"
	"     * @return $this\n"
	"     */\n"
	"    public function setName($name)\n"
	"    {\n"
	"        $this->name = $name;\n"
	"\n"
	"        return $this;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取版本\n"
	"     * @access public\n"
	"     * @return string\n"
	"     */\n"
	"    public function getVersion()\n"
	"    {\n"
	"        return $this->version;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置版本\n"
	"     * @access public\n"
	"     * @param  string $version 版本信息\n"
	"     * @return $this\n"
	"     */\n"
	"    public function setVersion($version)\n"
	"    {\n"
	"        $this->version = $version;\n"
	"\n"
	"        return $this;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取完整的版本号\n"
	"     * @access public\n"
	"     * @return string\n"
	"     */\n"
	"    public function getLongVersion()\n"
	"    {\n"
	"        if (\'UNKNOWN\' !== $this->getName() && \'UNKNOWN\' !== $this->getVersion()) {\n"
	"            return sprintf(\n"
	"                \'<info>%s</info> version <comment>%s</comment>\',\n"
	"                $this->getName(),\n"
	"                $this->getVersion()\n"
	"            );\n"
	"        }\n"
	"\n"
	"        return \'<info>Console Tool</info>\';\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 注册一个指令\n"
	"     * @access public\n"
	"     * @param string $name 指令名称\n"
	"     * @return Command\n"
	"     */\n"
	"    public function register($name)\n"
	"    {\n"
	"        return $this->add(new Command($name));\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 批量添加指令\n"
	"     * @access public\n"
	"     * @param  Command[] $commands 指令实例\n"
	"     * @return $this\n"
	"     */\n"
	"    public function addCommands(array $commands)\n"
	"    {\n"
	"        foreach ($commands as $command) $this->add($command);\n"
	"\n"
	"        return $this;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 添加一个指令\n"
	"     * @access public\n"
	"     * @param  Command $command 命令实例\n"
	"     * @return Command|bool\n"
	"     */\n"
	"    public function add(Command $command)\n"
	"    {\n"
	"        if (!$command->isEnabled()) {\n"
	"            $command->setConsole(null);\n"
	"            return false;\n"
	"        }\n"
	"\n"
	"        $command->setConsole($this);\n"
	"\n"
	"        if (null === $command->getDefinition()) {\n"
	"            throw new \\LogicException(\n"
	"                sprintf(\'Command class \"%s\" is not correctly initialized. You probably forgot to call the parent constructor.\', get_class($command))\n"
	"            );\n"
	"        }\n"
	"\n"
	"        $this->commands[$command->getName()] = $command;\n"
	"\n"
	"        foreach ($command->getAliases() as $alias) {\n"
	"            $this->commands[$alias] = $command;\n"
	"        }\n"
	"\n"
	"        return $command;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取指令\n"
	"     * @access public\n"
	"     * @param  string $name 指令名称\n"
	"     * @return Command\n"
	"     * @throws \\InvalidArgumentException\n"
	"     */\n"
	"    public function get($name)\n"
	"    {\n"
	"        if (!isset($this->commands[$name])) {\n"
	"            throw new \\InvalidArgumentException(\n"
	"                sprintf(\'The command \"%s\" does not exist.\', $name)\n"
	"            );\n"
	"        }\n"
	"\n"
	"        $command = $this->commands[$name];\n"
	"\n"
	"        if ($this->wantHelps) {\n"
	"            $this->wantHelps = false;\n"
	"\n"
	"            /** @var HelpCommand $helpCommand */\n"
	"            $helpCommand = $this->get(\'help\');\n"
	"            $helpCommand->setCommand($command);\n"
	"\n"
	"            return $helpCommand;\n"
	"        }\n"
	"\n"
	"        return $command;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 某个指令是否存在\n"
	"     * @access public\n"
	"     * @param  string $name 指令名称\n"
	"     * @return bool\n"
	"     */\n"
	"    public function has($name)\n"
	"    {\n"
	"        return isset($this->commands[$name]);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取所有的命名空间\n"
	"     * @access public\n"
	"     * @return array\n"
	"     */\n"
	"    public function getNamespaces()\n"
	"    {\n"
	"        $namespaces = [];\n"
	"\n"
	"        foreach ($this->commands as $command) {\n"
	"            $namespaces = array_merge(\n"
	"                $namespaces, $this->extractAllNamespaces($command->getName())\n"
	"            );\n"
	"\n"
	"            foreach ($command->getAliases() as $alias) {\n"
	"                $namespaces = array_merge(\n"
	"                    $namespaces, $this->extractAllNamespaces($alias)\n"
	"                );\n"
	"            }\n"
	"        }\n"
	"\n"
	"        return array_values(array_unique(array_filter($namespaces)));\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 查找注册命名空间中的名称或缩写\n"
	"     * @access public\n"
	"     * @param string $namespace\n"
	"     * @return string\n"
	"     * @throws \\InvalidArgumentException\n"
	"     */\n"
	"    public function findNamespace($namespace)\n"
	"    {\n"
	"        $expr = preg_replace_callback(\'{([^:]+|)}\', function ($matches) {\n"
	"            return preg_quote($matches[1]) . \'[^:]*\';\n"
	"        }, $namespace);\n"
	"\n"
	"        $allNamespaces = $this->getNamespaces();\n"
	"        $namespaces    = preg_grep(\'{^\' . $expr . \'}\', $allNamespaces);\n"
	"\n"
	"        if (empty($namespaces)) {\n"
	"            $message = sprintf(\n"
	"                \'There are no commands defined in the \"%s\" namespace.\', $namespace\n"
	"            );\n"
	"\n"
	"            if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) {\n"
	"                if (1 == count($alternatives)) {\n"
	"                    $message .= \"\\n\\nDid you mean this?\\n    \";\n"
	"                } else {\n"
	"                    $message .= \"\\n\\nDid you mean one of these?\\n    \";\n"
	"                }\n"
	"\n"
	"                $message .= implode(\"\\n    \", $alternatives);\n"
	"            }\n"
	"\n"
	"            throw new \\InvalidArgumentException($message);\n"
	"        }\n"
	"\n"
	"        $exact = in_array($namespace, $namespaces, true);\n"
	"\n"
	"        if (count($namespaces) > 1 && !$exact) {\n"
	"            throw new \\InvalidArgumentException(\n"
	"                sprintf(\n"
	"                    \'The namespace \"%s\" is ambiguous (%s).\',\n"
	"                    $namespace,\n"
	"                    $this->getAbbreviationSuggestions(array_values($namespaces)))\n"
	"            );\n"
	"        }\n"
	"\n"
	"        return $exact ? $namespace : reset($namespaces);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 查找指令\n"
	"     * @access public\n"
	"     * @param  string $name 名称或者别名\n"
	"     * @return Command\n"
	"     * @throws \\InvalidArgumentException\n"
	"     */\n"
	"    public function find($name)\n"
	"    {\n"
	"        $expr = preg_replace_callback(\'{([^:]+|)}\', function ($matches) {\n"
	"            return preg_quote($matches[1]) . \'[^:]*\';\n"
	"        }, $name);\n"
	"\n"
	"        $allCommands = array_keys($this->commands);\n"
	"        $commands    = preg_grep(\'{^\' . $expr . \'}\', $allCommands);\n"
	"\n"
	"        if (empty($commands) || count(preg_grep(\'{^\' . $expr . \'$}\', $commands)) < 1) {\n"
	"            if (false !== ($pos = strrpos($name, \':\'))) {\n"
	"                $this->findNamespace(substr($name, 0, $pos));\n"
	"            }\n"
	"\n"
	"            $message = sprintf(\'Command \"%s\" is not defined.\', $name);\n"
	"\n"
	"            if ($alternatives = $this->findAlternatives($name, $allCommands)) {\n"
	"                if (1 == count($alternatives)) {\n"
	"                    $message .= \"\\n\\nDid you mean this?\\n    \";\n"
	"                } else {\n"
	"                    $message .= \"\\n\\nDid you mean one of these?\\n    \";\n"
	"                }\n"
	"                $message .= implode(\"\\n    \", $alternatives);\n"
	"            }\n"
	"\n"
	"            throw new \\InvalidArgumentException($message);\n"
	"        }\n"
	"\n"
	"        if (count($commands) > 1) {\n"
	"            $commandList = $this->commands;\n"
	"            $commands    = array_filter($commands, function ($nameOrAlias) use ($commandList, $commands) {\n"
	"                $commandName = $commandList[$nameOrAlias]->getName();\n"
	"\n"
	"                return $commandName === $nameOrAlias || !in_array($commandName, $commands);\n"
	"            });\n"
	"        }\n"
	"\n"
	"        $exact = in_array($name, $commands, true);\n"
	"        if (count($commands) > 1 && !$exact) {\n"
	"            $suggestions = $this->getAbbreviationSuggestions(array_values($commands));\n"
	"\n"
	"            throw new \\InvalidArgumentException(\n"
	"                sprintf(\'Command \"%s\" is ambiguous (%s).\', $name, $suggestions)\n"
	"            );\n"
	"        }\n"
	"\n"
	"        return $this->get($exact ? $name : reset($commands));\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取所有的指令\n"
	"     * @access public\n"
	"     * @param  string $namespace 命名空间\n"
	"     * @return Command[]\n"
	"     */\n"
	"    public function all($namespace = null)\n"
	"    {\n"
	"        if (null === $namespace) return $this->commands;\n"
	"\n"
	"        $commands = [];\n"
	"\n"
	"        foreach ($this->commands as $name => $command) {\n"
	"            $ext = $this->extractNamespace($name, substr_count($namespace, \':\') + 1);\n"
	"\n"
	"            if ($ext === $namespace) $commands[$name] = $command;\n"
	"        }\n"
	"\n"
	"        return $commands;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取可能的指令名\n"
	"     * @access public\n"
	"     * @param  array $names 指令名\n"
	"     * @return array\n"
	"     */\n"
	"    public static function getAbbreviations($names)\n"
	"    {\n"
	"        $abbrevs = [];\n"
	"        foreach ($names as $name) {\n"
	"            for ($len = strlen($name); $len > 0; --$len) {\n"
	"                $abbrev             = substr($name, 0, $len);\n"
	"                $abbrevs[$abbrev][] = $name;\n"
	"            }\n"
	"        }\n"
	"\n"
	"        return $abbrevs;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 配置基于用户的参数和选项的输入和输出实例\n"
	"     * @access protected\n"
	"     * @param  Input  $input  输入实例\n"
	"     * @param  Output $output 输出实例\n"
	"     * @return void\n"
	"     */\n"
	"    protected function configureIO(Input $input, Output $output)\n"
	"    {\n"
	"        if (true === $input->hasParameterOption([\'--ansi\'])) {\n"
	"            $output->setDecorated(true);\n"
	"        } elseif (true === $input->hasParameterOption([\'--no-ansi\'])) {\n"
	"            $output->setDecorated(false);\n"
	"        }\n"
	"\n"
	"        if (true === $input->hasParameterOption([\'--no-interaction\', \'-n\'])) {\n"
	"            $input->setInteractive(false);\n"
	"        }\n"
	"\n"
	"        if (true === $input->hasParameterOption([\'--quiet\', \'-q\'])) {\n"
	"            $output->setVerbosity(Output::VERBOSITY_QUIET);\n"
	"        } else {\n"
	"            if ($input->hasParameterOption(\'-vvv\') || $input->hasParameterOption(\'--verbose=3\') || $input->getParameterOption(\'--verbose\') === 3) {\n"
	"                $output->setVerbosity(Output::VERBOSITY_DEBUG);\n"
	"            } elseif ($input->hasParameterOption(\'-vv\') || $input->hasParameterOption(\'--verbose=2\') || $input->getParameterOption(\'--verbose\') === 2) {\n"
	"                $output->setVerbosity(Output::VERBOSITY_VERY_VERBOSE);\n"
	"            } elseif ($input->hasParameterOption(\'-v\') || $input->hasParameterOption(\'--verbose=1\') || $input->hasParameterOption(\'--verbose\') || $input->getParameterOption(\'--verbose\')) {\n"
	"                $output->setVerbosity(Output::VERBOSITY_VERBOSE);\n"
	"            }\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 执行指令\n"
	"     * @access protected\n"
	"     * @param  Command $command 指令实例\n"
	"     * @param  Input   $input   输入实例\n"
	"     * @param  Output  $output  输出实例\n"
	"     * @return int\n"
	"     * @throws \\Exception\n"
	"     */\n"
	"    protected function doRunCommand(Command $command, Input $input, Output $output)\n"
	"    {\n"
	"        return $command->run($input, $output);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取指令的名称\n"
	"     * @access protected\n"
	"     * @param  Input $input 输入实例\n"
	"     * @return string\n"
	"     */\n"
	"    protected function getCommandName(Input $input)\n"
	"    {\n"
	"        return $input->getFirstArgument();\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取默认输入定义\n"
	"     * @access protected\n"
	"     * @return InputDefinition\n"
	"     */\n"
	"    protected function getDefaultInputDefinition()\n"
	"    {\n"
	"        return new InputDefinition([\n"
	"            new InputArgument(\'command\', InputArgument::REQUIRED, \'The command to execute\'),\n"
	"            new InputOption(\'--help\', \'-h\', InputOption::VALUE_NONE, \'Display this help message\'),\n"
	"            new InputOption(\'--version\', \'-V\', InputOption::VALUE_NONE, \'Display this console version\'),\n"
	"            new InputOption(\'--quiet\', \'-q\', InputOption::VALUE_NONE, \'Do not output any message\'),\n"
	"            new InputOption(\'--verbose\', \'-v|vv|vvv\', InputOption::VALUE_NONE, \'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug\'),\n"
	"            new InputOption(\'--ansi\', \'\', InputOption::VALUE_NONE, \'Force ANSI output\'),\n"
	"            new InputOption(\'--no-ansi\', \'\', InputOption::VALUE_NONE, \'Disable ANSI output\'),\n"
	"            new InputOption(\'--no-interaction\', \'-n\', InputOption::VALUE_NONE, \'Do not ask any interactive question\'),\n"
	"        ]);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取默认命令\n"
	"     * @access protected\n"
	"     * @return Command[]\n"
	"     */\n"
	"    protected function getDefaultCommands()\n"
	"    {\n"
	"        $defaultCommands = [];\n"
	"\n"
	"        foreach (self::$defaultCommands as $class) {\n"
	"            if (class_exists($class) && is_subclass_of($class, \"think\\\\console\\\\Command\")) {\n"
	"                $defaultCommands[] = new $class();\n"
	"            }\n"
	"        }\n"
	"\n"
	"        return $defaultCommands;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 添加默认指令\n"
	"     * @access public\n"
	"     * @param  array $classes 指令\n"
	"     * @return void\n"
	"     */\n"
	"    public static function addDefaultCommands(array $classes)\n"
	"    {\n"
	"        self::$defaultCommands = array_merge(self::$defaultCommands, $classes);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取可能的建议\n"
	"     * @access private\n"
	"     * @param  array $abbrevs\n"
	"     * @return string\n"
	"     */\n"
	"    private function getAbbreviationSuggestions($abbrevs)\n"
	"    {\n"
	"        return sprintf(\n"
	"            \'%s, %s%s\',\n"
	"            $abbrevs[0],\n"
	"            $abbrevs[1],\n"
	"            count($abbrevs) > 2 ? sprintf(\' and %d more\', count($abbrevs) - 2) : \'\'\n"
	"        );\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 返回指令的命名空间部分\n"
	"     * @access public\n"
	"     * @param  string $name  指令名称\n"
	"     * @param  string $limit 部分的命名空间的最大数量\n"
	"     * @return string\n"
	"     */\n"
	"    public function extractNamespace($name, $limit = null)\n"
	"    {\n"
	"        $parts = explode(\':\', $name);\n"
	"        array_pop($parts);\n"
	"\n"
	"        return implode(\':\', null === $limit ? $parts : array_slice($parts, 0, $limit));\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 查找可替代的建议\n"
	"     * @access private\n"
	"     * @param string             $name       指令名称\n"
	"     * @param array|\\Traversable $collection 建议集合\n"
	"     * @return array\n"
	"     */\n"
	"    private function findAlternatives($name, $collection)\n"
	"    {\n"
	"        $threshold       = 1e3;\n"
	"        $alternatives    = [];\n"
	"        $collectionParts = [];\n"
	"\n"
	"        foreach ($collection as $item) {\n"
	"            $collectionParts[$item] = explode(\':\', $item);\n"
	"        }\n"
	"\n"
	"        foreach (explode(\':\', $name) as $i => $subname) {\n"
	"            foreach ($collectionParts as $collectionName => $parts) {\n"
	"                $exists = isset($alternatives[$collectionName]);\n"
	"\n"
	"                if (!isset($parts[$i]) && $exists) {\n"
	"                    $alternatives[$collectionName] += $threshold;\n"
	"                    continue;\n"
	"                } elseif (!isset($parts[$i])) {\n"
	"                    continue;\n"
	"                }\n"
	"\n"
	"                $lev = levenshtein($subname, $parts[$i]);\n"
	"\n"
	"                if ($lev <= strlen($subname) / 3 ||\n"
	"                    \'\' !== $subname &&\n"
	"                    false !== strpos($parts[$i], $subname)\n"
	"                ) {\n"
	"                    $alternatives[$collectionName] = $exists ?\n"
	"                        $alternatives[$collectionName] + $lev :\n"
	"                        $lev;\n"
	"                } elseif ($exists) {\n"
	"                    $alternatives[$collectionName] += $threshold;\n"
	"                }\n"
	"            }\n"
	"        }\n"
	"\n"
	"        foreach ($collection as $item) {\n"
	"            $lev = levenshtein($name, $item);\n"
	"\n"
	"            if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) {\n"
	"                $alternatives[$item] = isset($alternatives[$item]) ?\n"
	"                    $alternatives[$item] - $lev :\n"
	"                    $lev;\n"
	"            }\n"
	"        }\n"
	"\n"
	"        $alternatives = array_filter($alternatives, function ($lev) use ($threshold) {\n"
	"            return $lev < 2 * $threshold;\n"
	"        });\n"
	"\n"
	"        asort($alternatives);\n"
	"\n"
	"        return array_keys($alternatives);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置默认的指令\n"
	"     * @access public\n"
	"     * @param string $commandName 指令名称\n"
	"     * @return $this\n"
	"     */\n"
	"    public function setDefaultCommand($commandName)\n"
	"    {\n"
	"        $this->defaultCommand = $commandName;\n"
	"\n"
	"        return $this;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 返回所有的命名空间\n"
	"     * @access private\n"
	"     * @param  string $name 指令名称\n"
	"     * @return array\n"
	"     */\n"
	"    private function extractAllNamespaces($name)\n"
	"    {\n"
	"        $namespaces = [];\n"
	"\n"
	"        foreach (explode(\':\', $name, -1) as $part) {\n"
	"            if (count($namespaces)) {\n"
	"                $namespaces[] = end($namespaces) . \':\' . $part;\n"
	"            } else {\n"
	"                $namespaces[] = $part;\n"
	"            }\n"
	"        }\n"
	"\n"
	"        return $namespaces;\n"
	"    }\n"
	"\n"
	"}\n"
	"\n"
;
#endif